//
//  ZSY_SearchEndTableViewCell.m
//  ZSY_BreadTrip
//
//  Created by 张诗宇 on 16/1/7.
//  Copyright © 2016年 张诗宇. All rights reserved.
//

#import "ZSY_SearchEndTableViewCell.h"

@interface ZSY_SearchEndTableViewCell ()

@property (nonatomic, retain) ZSY_BaseImageView *avatarImageView;
@property (nonatomic, retain) ZSY_BaseLabel *bioLabel;
@property (nonatomic, retain) ZSY_BaseLabel *genderLabel;

@end

@implementation ZSY_SearchEndTableViewCell

- (void)dealloc {
    [_users release];
    [_nameLabel release];
    [_avatarImageView release];
    [_bioLabel release];
    [_genderLabel release];
    [super dealloc];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (void)setUsers:(ZSY_SearchUserModel *)users {
    if (_users != users) {
        [_users release];
        _users = [users retain];
        
        NSURL *url = [NSURL URLWithString:_users.avatar_m];
        [self.avatarImageView sd_setImageWithURL:url];
        
        self.nameLabel.text = _users.name;
        self.nameLabel.font = [UIFont systemFontOfSize:15];
        [self.nameLabel sizeToFit];
        
        self.bioLabel.text = _users.bio;
        self.bioLabel.font = [UIFont systemFontOfSize:11];
        self.bioLabel.textColor = [UIColor lightGrayColor];
        [self.bioLabel sizeToFit];
        
        
    }
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubviews];
    }
    return self;
}

- (void)createSubviews {
    
//    self.contentView.backgroundColor = [UIColor colorWithRed:248 / 255.0 green:243 / 255.0 blue:233 / 255.0 alpha:1];
    
    self.avatarImageView = [[ZSY_BaseImageView alloc] initWithFrame:CGRectMake(10, 10, 40, 40)];
    self.avatarImageView.layer.cornerRadius = 20;
    self.avatarImageView.layer.masksToBounds = YES;
    [self.contentView addSubview:_avatarImageView];
    [_avatarImageView release];
    
    self.nameLabel = [[ZSY_BaseLabel alloc] initWithFrame:CGRectMake(60, 20, 100, 20)];
    [self.contentView addSubview:_nameLabel];
    [_nameLabel release];
    
    
    self.bioLabel = [[ZSY_BaseLabel alloc] initWithFrame:CGRectMake(60, 45, 100, 10)];
    [self.contentView addSubview:_bioLabel];
    [_bioLabel release];
    
    self.genderLabel = [[ZSY_BaseLabel alloc] initWithFrame:CGRectMake(WIDTH - 30, 20, 20, 20)];
    [self.contentView addSubview:_genderLabel];
    [_genderLabel release];
}

@end
